#include <stdio.h>
//
// Created by win10 on 2025/1/3.
//
int main() {
    int n,o,x;
    scanf("%d", &n);
    int queue[1000000],front = -1,rear = -1;
    for (int i = 0; i < n; i++) {
        scanf("%d", &o);
        if (o==1) {
            scanf("%d", &x);
            queue[++rear] = x;
        } else if (o==2) {
            if (front == rear) {
                printf("no\n");
            }else {
                printf("%d\n",queue[++front]);

            }
        }else if (o==3) {
            printf("%d\n",rear-front);
        }
    }
}